Skip to content

feat: Implement JWT authentication for profile API#148

Merged
joelamouche merged 2 commits intoTheSoftwareDevGuild:mainfrom
tusharshah21:feat-106-jwt
Dec 8, 2025
Merged

feat: Implement JWT authentication for profile API#148
joelamouche merged 2 commits intoTheSoftwareDevGuild:mainfrom
tusharshah21:feat-106-jwt

Conversation

@tusharshah21
Copy link
Collaborator

  • Add jsonwebtoken crate for HS256 JWT generation and validation
  • Create JWT service with token generation/validation methods
  • Implement JWT middleware that validates Bearer tokens
  • Maintain backward compatibility with existing SIWE signature auth
  • Add POST /auth/login endpoint that returns JWT token after signature verification
  • Add JWT_SECRET and JWT_EXPIRATION environment variables
  • Update auth flow: JWT tokens can be used instead of signing every request

The auth middleware now supports dual authentication:

  1. JWT Bearer token validation (faster, no signature verification needed)
  2. SIWE signature verification (existing flow, still works)

This allows clients to authenticate once, get a JWT, and use it for subsequent requests without having to sign every message.

Closes #106

Copy link
Contributor

@joelamouche joelamouche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🚀
Also I tested it locally and it works

@joelamouche joelamouche merged commit 7df6724 into TheSoftwareDevGuild:main Dec 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement JWT for our profile api - BACKEND

2 participants

Comments